package org.shock.ss.sms.commons.utils;

import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Set;


public class ParamsUtil {
	public static String transParams(Map<String, String[]> map) {
		StringBuffer sb = new StringBuffer();
		Set<String> set = map.keySet();
		for (String obj : set) {
			if (!obj.equals("pageno")&&!obj.equals("rownum")&&!"".equals( map.get(obj)[0])) {
				sb.append("&" + obj + "=" + URLEncoder(map.get(obj)[0]));
			}
		}
		return sb.toString();
	}
	
	
	/**当页面传字符串，而字符串中可能含有汉字是必须使用此转换字母编码集以避免出现乱码*/
	public static String URLEncoder(String s){
		String valueString="";
		if(s==null){
			valueString="";
		}
		try {
			valueString=java.net.URLEncoder.encode(s.toString(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return valueString;
	}
}
